package ru.amse.tsyganov.jumleditor.view.preferences;

import java.io.InputStream;

import org.eclipse.swt.graphics.Image;

public class Images {
	
	private static Image errorBigImage;
	
	private static Image errorImage;
	
	private static Image warningImage;
	
	private static Image undoEditImage;
	
	private static Image redoEditImage;
	
	private static Image selectImage;
	
	private static Image selectImageSelected;
	
	private static Image activityImage;
	
	private static Image activityImageSelected;
	
	private static Image initialStateImage;
	
	private static Image initialStateImageSelected;
	
	private static Image finalStateImage;
	
	private static Image finalStateImageSelected;
	
	private static Image joinStateImage;
	
	private static Image joinStateImageSelected;
	
	private static Image decisionForkImage;
	
	private static Image decisionForkImageSelected;
	
	private static Image decisionJoinImage;
	
	private static Image decisionJoinImageSelected;
	
	private static Image transitionImage;
	
	private static Image transitionImageSelected;
	
	private static Image communicationImage;
	
	private static Image communicationImageSelected;
	
	private static Image actorImage;
	
	private static Image actorImageSelected;
	
	private static Image instanceImage;
	
	private static Image instanceImageSelected;
	
	private static Image checkedImage;
	
	private static Image uncheckedImage;
	
	private static Image activityChartImage;
	
	private static Image collaborationChartImage;
	
	private static final ClassLoader CL = ClassLoader.getSystemClassLoader();
	
	public static Image getBigErrorImage() {
		if (errorBigImage == null) {
			errorBigImage = createImage("icons/BigError.gif");
		}
		return errorBigImage;
	}
	
	public static Image getErrorImage() {
		if (errorImage == null) {
			errorImage = createImage("icons/error.gif");
		}
		return errorImage;
	}
	
	public static Image getWarningImage() {
		if (warningImage == null) {
			warningImage = createImage("icons/warning.gif");
		}
		return warningImage;
	}
	
	public static Image getUndoEditImage() {
		if (undoEditImage == null) {
			undoEditImage = createImage("icons/undo_edit.gif");
		}
		return undoEditImage;
	}
	
	public static Image getRedoEditImage() {
		if (redoEditImage == null) {
			redoEditImage = createImage("icons/redo_edit.gif");
		}
		return redoEditImage;
	}
	
	public static Image getSelectImage() {
		if (selectImage == null) {
			selectImage = createImage("icons/select.png");
		}
		return selectImage;
	}
	
	public static Image getSelectImageSelected() {
		if (selectImageSelected == null) {
			selectImageSelected = createImage("icons/select_s.png");
		}
		return selectImageSelected;
	}
	
	public static Image getActivityImage() {
		if (activityImage == null) {
			activityImage = createImage("icons/activity.gif");
		}
		return activityImage;
	}
	
	public static Image getActivityImageSelected() {
		if (activityImageSelected == null) {
			activityImageSelected = createImage("icons/activity_s.gif");
		}
		return activityImageSelected;
	}
	
	public static Image getInitialStateImage() {
		if (initialStateImage == null) {
			initialStateImage = createImage("icons/initialState.gif");
		}
		return initialStateImage;
	}
	
	public static Image getInitialStateImageSelected() {
		if (initialStateImageSelected == null) {
			initialStateImageSelected = createImage("icons/initialState_s.gif");
		}
		return initialStateImageSelected;
	}
	
	public static Image getFinalStateImage() {
		if (finalStateImage == null) {
			finalStateImage = createImage("icons/finalState.gif");
		}
		return finalStateImage;
	}
	
	public static Image getFinalStateImageSelected() {
		if (finalStateImageSelected == null) {
			finalStateImageSelected = createImage("icons/finalState_s.gif");
		}
		return finalStateImageSelected;
	}
	
	public static Image getJoinImage() {
		if (joinStateImage == null) {
			joinStateImage = createImage("icons/join.gif");
		}
		return joinStateImage;
	}
	
	public static Image getJoinImageSelected() {
		if (joinStateImageSelected == null) {
			joinStateImageSelected = createImage("icons/join_s.gif");
		}
		return joinStateImageSelected;
	}
	
	public static Image getDecisionForkImage() {
		if (decisionForkImage == null) {
			decisionForkImage = createImage("icons/decision.gif");
		}
		return decisionForkImage;
	}
	
	public static Image getDecisionForkImageSelected() {
		if (decisionForkImageSelected == null) {
			decisionForkImageSelected = createImage("icons/decision_s.gif");
		}
		return decisionForkImageSelected;
	}
	
	public static Image getDecisionJoinImage() {
		if (decisionJoinImage == null) {
			decisionJoinImage = createImage("icons/decision_join.gif");
		}
		return decisionJoinImage;
	}
	
	public static Image getDecisionJoinImageSelected() {
		if (decisionJoinImageSelected == null) {
			decisionJoinImageSelected = createImage("icons/decision_join_s.gif");
		}
		return decisionJoinImageSelected;
	}
	
	public static Image getTransitionImage() {
		if (transitionImage == null) {
			transitionImage = createImage("icons/transition.gif");
		}
		return transitionImage;
	}
	
	public static Image getTransitionImageSelected() {
		if (transitionImageSelected == null) {
			transitionImageSelected = createImage("icons/transition_s.gif");
		}
		return transitionImageSelected;
	}
	
	public static Image getActorImage() {
		if (actorImage == null) {
			actorImage = createImage("icons/actor.gif");
		}
		return actorImage;
	}
	
	public static Image getActorImageSelected() {
		if (actorImageSelected == null) {
			actorImageSelected = createImage("icons/actor_s.gif");
		}
		return actorImageSelected;
	}
	
	public static Image getInstanceImage() {
		if (instanceImage == null) {
			instanceImage = createImage("icons/instance.gif");
		}
		return instanceImage;
	}
	
	public static Image getInstanceImageSelected() {
		if (instanceImageSelected == null) {
			instanceImageSelected = createImage("icons/instance_s.gif");
		}
		return instanceImageSelected;
	}
	
	public static Image getCommunicationImage() {
		if (communicationImage == null) {
			communicationImage = createImage("icons/communication.gif");
		}
		return communicationImage;
	}
	
	public static Image getCommunicationImageSelected() {
		if (communicationImageSelected == null) {
			communicationImageSelected = createImage("icons/communication_s.gif");
		}
		return communicationImageSelected;
	}
	
	public static Image getCheckedImage() {
		if (checkedImage == null) {
			checkedImage = createImage("icons/checked.gif");
		}
		return checkedImage;
	}
	
	public static Image getUncheckedImage() {
		if (uncheckedImage == null) {
			uncheckedImage = createImage("icons/unchecked.gif");
		}
		return uncheckedImage;
	}
	
	public static Image getActivityChartImage() {
		if (activityChartImage == null) {
			activityChartImage = createImage("icons/activityDiagram_on.gif");
		}
		return activityChartImage;
	}
	
	public static Image getCollaborationChartImage() {
		if (collaborationChartImage == null) {
			collaborationChartImage = createImage("icons/collaborationDiagram_on.gif");
		}
		return collaborationChartImage;
	}
	
	public static void dispose() {
		if (errorBigImage == null) {
			errorBigImage.dispose();
		}
		
		if (errorImage == null) {
			errorImage.dispose();
		}
		
		if (warningImage == null) {
			warningImage.dispose();
		}
		
		if (undoEditImage == null) {
			undoEditImage.dispose();
		}
		
		if (redoEditImage == null) {
			redoEditImage.dispose();
		}
		
		if (selectImage == null) {
			selectImage.dispose();
		}
		
		if (selectImageSelected == null) {
			selectImageSelected.dispose();
		}
		
		if (activityImage == null) {
			activityImage.dispose();
		}
		
		if (initialStateImage == null) {
			initialStateImage.dispose();
		}
		
		if (finalStateImage == null) {
			finalStateImage.dispose();
		}
		
		if (joinStateImage == null) {
			joinStateImage.dispose();
		}
		
		if (decisionForkImage == null) {
			decisionForkImage.dispose();
		}
		
		if (decisionJoinImage == null) {
			decisionJoinImage.dispose();
		}
		
		if (transitionImage == null) {
			transitionImage.dispose();
		}
		
		if (activityImageSelected == null) {
			activityImageSelected.dispose();
		}
		
		if (initialStateImageSelected == null) {
			initialStateImageSelected.dispose();
		}
		
		if (finalStateImageSelected == null) {
			finalStateImageSelected.dispose();
		}
		
		if (joinStateImageSelected == null) {
			joinStateImageSelected.dispose();
		}
		
		if (decisionForkImageSelected == null) {
			decisionForkImageSelected.dispose();
		}
		
		if (decisionJoinImageSelected == null) {
			decisionJoinImageSelected.dispose();
		}
		
		if (transitionImageSelected == null) {
			transitionImageSelected.dispose();
		}
		
		if (actorImageSelected == null) {
			actorImageSelected.dispose();
		}
		
		if (actorImage == null) {
			actorImage.dispose();
		}
		
		if (instanceImageSelected == null) {
			instanceImageSelected.dispose();
		}
		
		if (instanceImage == null) {
			instanceImage.dispose();
		}
		
		if (communicationImageSelected == null) {
			communicationImageSelected.dispose();
		}
		
		if (communicationImage == null) {
			communicationImage.dispose();
		}
		
		if (checkedImage == null) {
			checkedImage.dispose();
		}
		
		if (uncheckedImage == null) {
			uncheckedImage.dispose();
		}
		
		if (activityChartImage == null) {
			activityChartImage.dispose();
		}
		
		if (collaborationChartImage == null) {
			collaborationChartImage.dispose();
		}
	}
	
	public static Image createImage(String path) {
		//InputStream is = CL.getResourceAsStream(path);
		//Image image = new Image(null, is);
		//return image;
		return new Image(null, path);
	}
}
